<%--                                                                       --%>
<%-- Copyright (c) 2005 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld"    prefix="bean" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<%@ page import =  "com.broadvision.web.util.ViewDynaBean,
		    org.apache.struts.validator.DynaValidatorForm,
                    org.apache.commons.beanutils.PropertyUtils,
                    org.apache.struts.action.DynaActionForm,
                    java.util.List"
%>

<jsp:useBean id="cmVersionsListView" scope="request" type="com.broadvision.web.util.ViewDynaBean"/>

<SCRIPT language="javascript">
 function doWebflowAction(theForm,cntOID,version,cntAction){
   var theURL="/cm/launchVSWebflow.do";
   var theParam="?guid="+cntOID+"&version="+version+
             "&launchAction="+cntAction+"&exitURL="+"/cm/closeWindowAlwaysRefresh.do";
   var url = '<html-el:rewrite page="'+theURL+'" />'+theParam;
   var qualifier = window.open(url, "ContentServiceLaunchProcess",
                               "directories=no,height=500,width=650,left=50,top=50,resizable=yes,scrollbars=yes,location=yes,menubar=yes,status=yes,toolbar=yes");

  if (qualifier != null){
    if (qualifier.opener == null)
        qualifier.opener = self;
    qualifier.focus();
  }

 }

 function doBVCWebflowAction(theForm,cntOID,version,cntAction){
   var theURL="/cm/launchBVCViewHistory.do";
   var theParam="?guid="+cntOID+"&version="+version+
              "&launchAction="+cntAction+"&cntTypeId="+theForm.cntTypeId.value+
              "&exitURL=/cm/closeWindowAlwaysRefresh.do";
   var url = '<html-el:rewrite page="'+theURL+'" />'+theParam;
   var qualifier = window.open(url, "ContentServiceLaunchProcess",
                               "directories=no,height=500,width=650,left=50,top=50,resizable=yes,scrollbars=yes,location=yes,menubar=yes,status=yes,toolbar=yes");

  if (qualifier != null){
    if (qualifier.opener == null)
        qualifier.opener = self;
    qualifier.focus();
  }
 }

 function doCopyBackAction(theForm, guid, contentOid, version) {
   var theURL="/cm/copyBack.do";
   var theParam="?guid="+guid+"&contentOid="+contentOid+"&version="+version;
   var url = '<html-el:rewrite page="'+theURL+'" />'+theParam;
   theForm.action = url;
   theForm.submit();
   return false;
 }

 function doRefresh() {
   var theForm = document.forms["cmCntBrowseForm"];
   theForm.action = '<html-el:rewrite page="/cm/viewHistory.do"/>'+"?cntTypeId="+theForm.cntTypeId.value+"&contentOid="+'<c:out value="${cmVersionsListView.map.contentOid}"/>';
   theForm.submit();
 }

</script>


<% String ctxPath = request.getContextPath(); %>

<html-el:form action="/cm/contentBrowse.do">
<html-el:hidden property="formIsCntSvcsContent"/>
<html-el:hidden property="cntTypeId"/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
<tr>
  <td valign="top" width="100%">
    <div class="pageTitle">
    <bean-el:message bundle="cm.messages" key="cm.browse.revisions.title"/> - <c:out value="${cmVersionsListView.map.key}"/>
    </div>
    <div class="errorMessage"><html-el:errors bundle="cm.messages"/></div>

    <div class="pageSubtitle">
      <span class="left"><bean-el:message bundle="cm.messages" key="cm.browse.revisions.info"/></span>
      <span class="right">&nbsp;</span>
    </div>

    <table class="dataTable" border="0" cellspacing="1" cellpadding="2" width="100%" summary="Content table">
    <tr class="listHeader">
      <th id="Content Name" align="left"><bean-el:message bundle="cm.messages" key="cm.browse.revisions.name"/></th>
      <th id="Version" align="left"><bean-el:message bundle="cm.messages" key="cm.browse.revisions.version"/></th>
      <th id="Type" align="left" nowrap><bean-el:message bundle="cm.messages" key="cm.browse.revisions.type"/></th>
      <th id="Modified on" align="left" nowrap><bean-el:message bundle="cm.messages" key="cm.browse.revisions.modifiedOn"/></th>
      <th id="Modified by" align="left" nowrap><bean-el:message bundle="cm.messages" key="cm.browse.revisions.modifiedBy"/></th>
      <th id="Action" align="left" nowrap><bean-el:message bundle="cm.messages" key="header.actions"/></th>
    </tr>

    <c:set var="editImg">
      <img src="<%=ctxPath%>/mc/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean-el:message bundle="cm.messages" key="image.alt.edit"/>' title='<bean-el:message bundle="cm.messages" key="image.alt.edit"/>'>
    </c:set>
    <c:set var="publishImg">
      <img src="<%=ctxPath%>/mc/images/action/icon_publish.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean-el:message bundle="cm.messages" key="image.alt.copyBack"/>' title='<bean-el:message bundle="cm.messages" key="image.alt.copyBack"/>'>
    </c:set>

    <c:choose>
    <c:when test="${not empty cmVersionsListView.map.versionsList}">
    <c:forEach var="content" items="${cmVersionsListView.map.versionsList}" varStatus="status">
      <c:choose>
      <c:when test="${(status.count + 1) % 2 == 0}">
        <tr class="listEven">
      </c:when>
      <c:otherwise>
	<tr class="listOdd">
      </c:otherwise>
      </c:choose>

      <td headers="Content Name">
        <c:if test="${cmVersionsListView.map.isPublish=='false'}">
            <a href="JavaScript:doWebflowAction(document.cmCntBrowseForm,'<c:out value="${cmVersionsListView.map.guid}"/>','<c:out value="${content.map.version}"/>','View')" >
        </c:if>
        <c:if test="${cmVersionsListView.map.isPublish=='true'}">
            <a href="JavaScript:doBVCWebflowAction(document.cmCntBrowseForm,'<c:out value="${cmVersionsListView.map.guid}"/>','<c:out value="${content.map.version}"/>','ViewVersion')" >
        </c:if>
        <c:out value="${content.map.contentName}"/></a>
      </td>
      <td headers="Revision">
        <c:choose>
        <c:when test="${content.map.version == -1}">
          <bean-el:message bundle="cm.messages" key="cm.browse.revisions.workingCopy"/>
        </c:when>
        <c:otherwise>
          <c:out value="${content.map.version}"/>
        </c:otherwise>
        </c:choose>
      </td>
      <td headers="Type"><c:out value="${content.map.contentObjectType}"/></td>
      <td headers="Modified on">
      <bean:write name="content" property="versionCreatedTime" bundle="cm.messages" formatKey="format.datetime.long"/>


      </td>
      <td headers="Modified by"><c:out value="${content.map.versionCreatedBy}"/></td>
      <td headers="Actions">
        <c:if test="${cmVersionsListView.map.isPublish=='false'}">
            <a href="JavaScript:doWebflowAction(document.cmCntBrowseForm,'<c:out value="${cmVersionsListView.map.guid}"/>','<c:out value="${content.map.version}"/>','Edit')" >
            <c:out value='${editImg}' escapeXml="false"/></a>
        </c:if>
        <c:choose>
        <c:when test="${cmVersionsListView.map.isPublish == 'true'}">
          <a href="JavaScript:doCopyBackAction(document.cmCntBrowseForm,'<c:out value="${cmVersionsListView.map.guid}"/>','<c:out value="${cmVersionsListView.map.contentOid}"/>','<c:out value="${content.map.version}"/>')">
            <c:out value='${publishImg}' escapeXml="false"/></a>
        </c:when>
        </c:choose>
      </td>

      </tr>
    </c:forEach>
    </c:when>
    <c:otherwise>
      <tr class="listOdd">
        <td colspan=7 align="center"><bean-el:message key="cm.browse.revisions.noContent" bundle="cm.messages"/></td>
      </tr>
    </c:otherwise>
    </c:choose>
    </table>

  </td>
</tr>
</table>

</html-el:form>

